//index.js
//获取应用实例
const app = getApp();
const base_url = app.globalData.base_url;
const util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ad_url: ''
  },
  onLoad: function (options) {
    var id = decodeURIComponent(options.id);

    wx.request({
      url: base_url + '/Pub/getAdUrl',
      method: 'POST',
      data: {
        'id': id,
        'user_token': JSON.parse(wx.getStorageSync("user")).user_token
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res)
        if (res.data.success == '1') {
          this.setData({
            ad_url: res.data.data.url
          })
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          })
        }
      }
    })
  },

})
